

<script type="text/javascript">
	var CI = {
    	baseUrl: "<?= base_url(); ?>"
    };
    
	$(document).ready(function(){
		$("#assigned_to").autocomplete({
			source: CI.baseUrl + "index.php/user/get_json_users_autocomplete",
			minLength: 2,
			select: function( event, ui ) {
				$("#assigned_to_id").val(ui.item.id);			
			}
		});
	});
</script>

<?= form_open('index.php/tasks/upsert_task'); ?>
	<div class="box">
		<div class="container">
			<p>
				<?= form_hidden('id', isset($task) ? $task['id'] : ''); ?>
				<label for="subject">Subject</label> 
				<?= form_input(
					'subject', 
					isset($task) ? $task['subject'] : "", 
					'id="subject", size="80"'
					); 
				?>
			</p>
			<p>
				<label for="description">Description</label>
				<?= form_textarea(
					'description', 
					isset($task) ? $task['description'] : "", 
					'id="description", cols="80", rows="10"'
					); 
				?>
			</p>
		</div>
		
		<div class="container_left">
			<p>
				<label for="priority">Priority</label>
				<?= form_dropdown(
					'priority', 
					$general['priority_options'], 
					isset($task) ? $task['priority'] : NULL, 
					'id="priority"'
					);
				?>
			</p>
			<p>
				<label for="status">Status</label>
				<?= form_dropdown(
					'status', 
					$general['status_options'], 
					isset($task) ? $task['status'] : NULL, 
					'id="status"'
					);
				?>
			</p>
			<p>
				<label for="assigned_to">Assigned to</label>
				<?= form_input(
					'assigned_to', 
					isset($task) ? $task['username'] : "", 
					'id="assigned_to"'
					); 
				?>
				<input id="assigned_to_id" type="hidden" value="<?= isset($task) ? $task['user'] : "" ?>"/>
				
			</p>
		</div>
		
		<div class="container_right">
			<p>
				<label for="estimated_hours">Estimated hours</label>
				<?= form_input(
					'estimated_hours', 
					isset($task) ? $task['estimated_hours'] : "", 
					'id="estimated_hours"'
					); 
				?>
			</p>
			<p>
				<label for="worked_hours">Worked hours</label>
				<?= form_input(
					'worked_hours', 
					isset($task) ? $task['worked_hours'] : "", 
					'id="worked_hours"'
					); 
				?>
			</p>
			<p>
				<label for="completed">% Completed</label>
				<select id="completed"></select>
			</p>
		</div>
	</div>
	<?= form_submit('save', 'Save'); ?>


<?php $this->load->view('includes/footer'); ?>